package com.neusoft.lohas.modules.ivm.entity.business;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import com.neusoft.lohas.common.persistence.IdEntity;
/**
 * 商圈最新优惠类(功能为热点图片形式)
 * @author jackie.liu
 * @version 2015-01-29
 */
@Entity
@Table(name = "ivm_business_concession_photo")
@DynamicInsert
@DynamicUpdate
public class ConcessionPhoto extends IdEntity<ConcessionPhoto> {

	private static final long serialVersionUID = 1L;
	private Concession concession; // 商户信息
	private String logoUrl; //图片地址
	private int sort; //排序号
	
	private List<ConcessionHot> hotList = Lists.newArrayList(); // 热点位置列表
	
	public ConcessionPhoto() {
		super();
		this.sort = 30;
	}

	public ConcessionPhoto(String id) {
		this();
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name="concession_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@JsonIgnore
	@NotNull(message="所属最新优惠信息信息不能为空")
	public Concession getConcession() {
		return concession;
	}

	public void setConcession(Concession concession) {
		this.concession = concession;
	}

	public String getLogoUrl() {
		return logoUrl;
	}

	public void setLogoUrl(String logoUrl) {
		this.logoUrl = logoUrl;
	}

	public int getSort() {
		return sort;
	}

	public void setSort(int sort) {
		this.sort = sort;
	}

	@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "concessionPhoto")
	@Where(clause="del_flag='"+DEL_FLAG_NORMAL+"'")
	@OrderBy("create_date")
	@NotFound(action = NotFoundAction.IGNORE)
	public List<ConcessionHot> getHotList() {
		return hotList;
	}

	public void setHotList(List<ConcessionHot> hotList) {
		this.hotList = hotList;
	}
	
}
